#include<iostream>
using namespace std;
class Product
{
    char *name;
    int price;
    int quantity;
public:
    Product(char *n,int p,int q);
    ~Product();
    void buy(int money);
    void get()const;
};
Product::Product(char *n,int p,int q)
{
    name = n;
    price = p;
    quantity = q;
}
Product::~Product(){}
void Product::buy(int money)
{
    int r,n;
    n = money/price;
    r = money%price;
    if(n > quantity)
    {
        cout<<"数量不够"<<endl;
    }
    else
    {
        quantity -= n;
        cout<<"名称："<<name<<",单价："<<price<<"元"<<endl;
        cout<<"顾客使用"<<money<<"元，购买"<<n<<"台，剩余"<<r<<"元"<<endl;
    }
}
void Product::get()const
{
    cout<<"产品："<<name<<",单价："<<price<<",剩余："<<quantity<<"台"<<endl;
}
int main()
{
    Product p("Iphone14",12999,20);
    p.buy(10);
    p.get();
    cout<<"\n==========================\n"<<endl;
    p.buy(1000);
    p.get();
    return 0;
}
